package com.example.myapplication.kotlin

fun main() {
    //可变
    val m1 = mutableMapOf(
        "monkey" to "🐒",
        "chicken" to "🐓",
        "dog" to "🐕",
        "pig" to "🐖",
    )
    println(m1["monkey"])
    m1["monkey"] = "🐒🐒"
    println(m1["monkey"])
    m1["sheep"] = "🐑"
    println(m1["sheep"])
    m1.remove("dog")
    println(m1["dog"])

    // 不可变 map
//    val m1 = mapOf(
//        "breakfast" to "早餐",
//        "lunch" to "午餐",
//        "dinner" to "晚餐"
//    )
//    println(m1["lunch"])
//    println(m1["drink"]) // 取不到是null
//    //    m1["lunch"] = "" // 直接报错
//    m1.forEach({ key, value -> println("$key: $value") })
}